<template>
	<view class="container">
		<view class="line"></view>
		<view class="list">
			<view class="item">
				<view class="text">设置以下信息是否对其他用户可见</view>
				<view class="text">不可见/可见</view>
			</view>
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="label">{{item.label}}</view>
				<u-switch v-model="item.value" active-color="#4B9CFF" inactive-color="#D6D7DA">></u-switch>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					label: '企业名称',
					value: false,
					name: 'name'
				}, {
					label: '企业分类',
					value: false,
					name: 'industry'
				}, {
					label: '企业性质',
					value: false,
					name: 'type'
				}, {
					label: '执照照片',
					value: false,
					name: 'photo'
				}, {
					label: '企业地址',
					value: false,
					name: 'address'
				}, {
					label: '质量体系',
					value: false,
					name: 'quality'
				}, {
					label: '质量体系照片',
					value: false,
					name: 'credentials'
				}, {
					label: '擅长领域',
					value: false,
					name: 'specials'
				}, {
					label: '人员规模',
					value: false,
					name: 'scale'
				}, {
					label: '赞助申请',
					value: false,
					name: 'support'
				}, {
					label: '接受应聘',
					value: false,
					name: 'acceptRecruit'
				}, {
					label: '联系人',
					value: false,
					name: 'contactName'
				}, {
					label: '联系电话',
					value: false,
					name: 'contactPhone'
				}, {
					label: '企业邮箱',
					value: false,
					name: 'mail'
				}, {
					label: '自评标签',
					value: false,
					name: 'selfTag'
				},{
					label: '自我评价',
					value: false,
					name: 'introduction'
				},]
			};
		},
		onNavigationBarButtonTap() {
			let arr = [];
			this.list.forEach(function(item) {
				if (item.value) {
					arr.push(item.name)
				}
			})
			var pages = getCurrentPages();
			var prevPage = pages[pages.length - 2];
			// #ifdef APP-PLUS
			prevPage.$vm.customize = arr.join(',');
			prevPage.$vm.customizeFlag = true;			
			// #endif
			this.editCustomize(arr.join(','));
			uni.navigateBack({
				delta: 1
			})
		},
		onLoad(opt) {
			console.log('opt',opt)
			if(opt.row != ''){
				this.list.forEach(function(ele){
					if(opt.row != undefined){
						if(opt.row.indexOf(',') != -1 ){			
							if(opt.row.indexOf(ele.name) != -1){
								ele.value = true;
							}
						}else{
							if(opt.row == ele.name){
								ele.value = true;
							}
						}
					}
				})
			}
		},
		methods: {
			async editCustomize(customize){
				let result = await this.$apis.editCustomize( { customize:customize});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;

		.list {
			width: 100%;

			.item {
				width: 100%;
				display: flex;
				height: 100upx;
				align-items: center;
				justify-content: space-between;
				padding: 0 30upx;

				.text {
					color: #9DA2B0;
					font-size: 26upx;
				}

				.label {
					color: #0D1D36;
					font-size: 30upx;
				}
			}
		}

		.line {
			width: 100%;
			height: 20upx;
			background: #F5F5F9;
		}
	}
</style>
